package cn.home.web.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.home.common.annotation.Log;
import cn.home.common.core.controller.BaseController;
import cn.home.common.core.domain.AjaxResult;
import cn.home.common.enums.BusinessType;
import cn.home.web.domain.Aa;
import cn.home.web.service.IAaService;
import cn.home.common.utils.poi.ExcelUtil;
import cn.home.common.core.page.TableDataInfo;

/**
 * aaController
 * 
 * @author homedoctor
 * @date 2025-04-08
 */
@RestController
@RequestMapping("/aa/aa")
public class AaController extends BaseController
{
    @Autowired
    private IAaService aaService;

    /**
     * 查询aa列表
     */
    @PreAuthorize("@ss.hasPermi('aa:aa:list')")
    @GetMapping("/list")
    public TableDataInfo list(Aa aa)
    {
        startPage();
        List<Aa> list = aaService.selectAaList(aa);
        return getDataTable(list);
    }

    /**
     * 导出aa列表
     */
    @PreAuthorize("@ss.hasPermi('aa:aa:export')")
    @Log(title = "aa", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Aa aa)
    {
        List<Aa> list = aaService.selectAaList(aa);
        ExcelUtil<Aa> util = new ExcelUtil<Aa>(Aa.class);
        util.exportExcel(response, list, "aa数据");
    }

    /**
     * 获取aa详细信息
     */
    @PreAuthorize("@ss.hasPermi('aa:aa:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aaService.selectAaById(id));
    }

    /**
     * 新增aa
     */
    @PreAuthorize("@ss.hasPermi('aa:aa:add')")
    @Log(title = "aa", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Aa aa)
    {
        return toAjax(aaService.insertAa(aa));
    }

    /**
     * 修改aa
     */
    @PreAuthorize("@ss.hasPermi('aa:aa:edit')")
    @Log(title = "aa", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Aa aa)
    {
        return toAjax(aaService.updateAa(aa));
    }

    /**
     * 删除aa
     */
    @PreAuthorize("@ss.hasPermi('aa:aa:remove')")
    @Log(title = "aa", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aaService.deleteAaByIds(ids));
    }
}
